﻿using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TunnelManager.Tools;

namespace TunnelManager.SearchAndReport.Alarm
{
    public partial class Alarm_DayReport : Form
    {
        public Alarm_DayReport()
        {
            InitializeComponent();
        }

        private void Alarm_DayReport_Load(object sender, EventArgs e)
        {

            LocationPut();

            TranTheParam();
            alarm_DayReportTableAdapter.Fill(tunnelXAT1DataSet.Alarm_DayReport, dateTimePicker.Value.Year, dateTimePicker.Value.Month, dateTimePicker.Value.Day);
            this.reportViewer1.RefreshReport();
        }

        private void button_watch_Click(object sender, EventArgs e)
        {
            TranTheParam();
            alarm_DayReportTableAdapter.Fill(tunnelXAT1DataSet.Alarm_DayReport, dateTimePicker.Value.Year, dateTimePicker.Value.Month, dateTimePicker.Value.Day);
            this.reportViewer1.RefreshReport();
        }

        private void Alarm_DayReport_Resize(object sender, EventArgs e)
        {
            LocationPut();
        }
        private void TranTheParam()
        {
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter("date", dateTimePicker.Value.ToShortDateString()));
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter("user", User.Username));
            
        }

        /// <summary>
        /// 重新放置各控件位置
        /// </summary>
        private void LocationPut()
        {
            reportViewer1.Size = new Size(this.ClientSize.Width, this.ClientSize.Height - 93);
            panel1.Location = new Point(500, this.ClientSize.Height - 80);
        }
    }
}
